import 'package:dio/dio.dart';
/*class DioRendingView extends StatefulWidget {
  const DioRendingView({super.key});

  @override
  State<DioRendingView> createState() => _DioRendingViewState();
}

class _DioRendingViewState extends State<DioRendingView> {
  @override
  Widget build(BuildContext context) {
    return const Placeholder();
  }
}*/

import 'package:flutter/material.dart';

class DioRendingView extends StatefulWidget {
  const DioRendingView({super.key});
  @override
  State<DioRendingView> createState() => _CategoryPageState();
}

class _CategoryPageState extends State<DioRendingView> {
  List _list = [];
  @override
  void initState() {
    super.initState();
    _getCateList();
  }

  _getCateList() async {
    var response = await Dio().get("https://jdmall.itying.com/api/pcate");
// return result.data;
    print('_getCateList ${response.data}');
    setState(() {
      _list = response.data["result"];
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text('列表数据 Dio  测试')),
        body: _list.isNotEmpty
            ? ListView(
                children: _list.map((value) {
                  return Column(
                    children: [
                      ListTile(
                        title: Text(value["title"]),
                      ),
                      const Divider()
                    ],
                  );
                }).toList(),
              )
            : const Center(
                child: CircularProgressIndicator(),
              ));
  }
}
